package com.sinog.front.controller.api;

import com.sinog.core.utilbean.Result;
import com.sinog.core.utilbean.ReturnCode;
import com.sinog.front.feign.basic.SjUserService;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @desc 获取最新的社矫账号集合 curl调用 curl -XGET http://ip:端口/azbj/user/getSjUserAll，社区矫正对接省份获取安置帮教最新的社区矫正账号
 * @author lj
 * @date -
 */
@RestController
public class SjUserController {

    @Resource
    private SjUserService sjUserService;

    /**
     * 获取安置帮教社矫账号(社矫中心)集合
     * 例:curl -XGET http://192.168.1.220:8080/azbj/user/getSjUserAll
     * departid 司法所部门id（由社矫中心id,演变过来的）
     * account  社矫中心账号
     * username 社矫中心用户名
     * @return Result
     */
    @RequestMapping("/azbj/user/getSjUserAll")
    public Result getSjUserAll() {
        List<Map<String,String>> sjUserAll = sjUserService.getSjUserAll();
        if(!CollectionUtils.isEmpty(sjUserAll)) {
            return Result.success(sjUserAll);
        } else {
            return Result.failure(ReturnCode.INTERFACE_USER_NOT_FOUND);
        }
    }
}